﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using YArchitech.Controls;
using YJKArch.Ramp;
using YJKArchStandard;

namespace ModelValidation.StairsRamp
{
	internal class RampData
	{
		public static int GetRampSlope(Element group)
		{
			List<string> list = BarrierFreeRampManager.ReadXData(group);
			if (list.Count < 1 || list.Count < 21)
			{
				YJKMessageBox.Show("不能提取坡道参数。");
				return -1;
			}
			return Convert.ToInt32(list[1].Trim(new char[]
			{
				'1'
			}).Trim(new char[]
			{
				':'
			}));
		}

		public static int GetRampMaxHeight(Element group)
		{
			List<string> list = BarrierFreeRampManager.ReadXData(group);
			if (list.Count < 1 || list.Count < 21)
			{
				YJKMessageBox.Show("不能提取坡道参数。");
				return -1;
			}
			return Convert.ToInt32(list[2]);
		}

		public static int GetRampWidth(Element group)
		{
			List<string> list = BarrierFreeRampManager.ReadXData(group);
			if (list.Count < 1 || list.Count < 21)
			{
				YJKMessageBox.Show("不能提取坡道参数。");
				return -1;
			}
			return Convert.ToInt32(list[3]);
		}

		public static int GetLandLength(Element group)
		{
			List<string> list = BarrierFreeRampManager.ReadXData(group);
			if (list.Count < 1 || list.Count < 21)
			{
				YJKMessageBox.Show("不能提取坡道参数。");
				return -1;
			}
			return Convert.ToInt32(list[4]);
		}

		public static List<int> GetRampLength(Element group)
		{
			List<int> list = new List<int>();
			List<string> list2 = BarrierFreeRampManager.ReadXData(group);
			if (list2.Count < 1 || list2.Count < 21)
			{
				YJKMessageBox.Show("不能提取坡道参数。");
				return null;
			}
			if ("直线型" == list2[12])
			{
				list.Add(Convert.ToInt32(list2[6]));
			}
			else if ("直角型" == list2[12])
			{
				list.Add(Convert.ToInt32(list2[6]));
				list.Add(Convert.ToInt32(list2[7]));
			}
			else if ("折返型1" == list2[12])
			{
				list.Add(Convert.ToInt32(list2[6]));
				list.Add(Convert.ToInt32(list2[7]));
				list.Add(Convert.ToInt32(list2[8]));
			}
			else if ("折返型2" == list2[12])
			{
				list.Add(Convert.ToInt32(list2[6]));
				list.Add(Convert.ToInt32(list2[7]));
				list.Add(Convert.ToInt32(list2[8]));
				list.Add(Convert.ToInt32(list2[9]));
			}
			return list;
		}

		public static string GetValidatingData(List<RampValidationData> listValidatingData)
		{
			string text = null;
			string archStdXmlPath = ValidationStandard.GetArchStdXmlPath();
			RampArchStd instance = RampArchStd.GetInstance("GB50763-2012", archStdXmlPath);
			foreach (RampValidationData rampValidationData in listValidatingData)
			{
				string text2 = null;
				switch (rampValidationData.Type)
				{
				case RampDataType.RDT_RampSlope:
					if (!instance.CheckRampSlope(rampValidationData.Value, ref text2, false))
					{
						text = text + text2 + "\n";
					}
					break;
				case RampDataType.RDT_RampMaxHeight:
					if (!instance.CheckRampMaxHeight(rampValidationData.Slope, rampValidationData.Value, ref text2, false))
					{
						text = text + text2 + "\n";
					}
					break;
				case RampDataType.RDT_RampWidth:
					if (!instance.CheckRampWidth(rampValidationData.Slope, rampValidationData.Value, ref text2, false))
					{
						text = text + text2 + "\n";
					}
					break;
				case RampDataType.RDT_RampLength:
					if (!instance.CheckRampHorizontalLength(rampValidationData.Slope, rampValidationData.Value, ref text2, false))
					{
						text = text + rampValidationData.Name + text2 + "\n";
					}
					break;
				case RampDataType.RDT_LandLength:
					if (!instance.CheckLandHorizontalLength(rampValidationData.Slope, rampValidationData.Value, ref text2, false))
					{
						text = text + text2 + "\n";
					}
					break;
				}
			}
			return text;
		}
	}
}
